import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MultiDictVO, MultiDictForm, MultiDictQuery } from '@/api/business/multiDict/types';

/**
 * 查询多级字典列表
 * @param query
 * @returns {*}
 */

export const listMultiDict = (query?: MultiDictQuery): AxiosPromise<MultiDictVO[]> => {
  return request({
    url: '/business/multiDict/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询多级字典详细
 * @param baseId
 */
export const getMultiDict = (baseId: string | number): AxiosPromise<MultiDictVO> => {
  return request({
    url: '/business/multiDict/' + baseId,
    method: 'get'
  });
};

/**
 * 新增多级字典
 * @param data
 */
export const addMultiDict = (data: MultiDictForm) => {
  return request({
    url: '/business/multiDict',
    method: 'post',
    data: data
  });
};

/**
 * 修改多级字典
 * @param data
 */
export const updateMultiDict = (data: MultiDictForm) => {
  return request({
    url: '/business/multiDict',
    method: 'put',
    data: data
  });
};

/**
 * 删除多级字典
 * @param baseId
 */
export const delMultiDict = (baseId: string | number | Array<string | number>) => {
  return request({
    url: '/business/multiDict/' + baseId,
    method: 'delete'
  });
};
